package RedisDay2;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.Tuple;

import java.util.HashMap;
import java.util.Set;

public class Redis_ZSet {
    public static void main(String[] args) {
        Jedis master = new Jedis("192.168.111.166", 7000);
        master.select(3);
//        HashMap<String,Double> map = new HashMap<>();
//        map.put("小龙",100.0);
//        map.put("小虎",110.0);
//        map.put("小风",99.0);
//        master.zadd("score",map);
        //查看
        Set<Tuple> score = master.zrangeWithScores("score", 0, 10);
        System.out.println(master.exists("score"));
        for (Tuple tuple : score) {
            System.out.println(tuple.getElement());
            System.out.println(tuple.getScore());
            System.out.println(tuple.getBinaryElement());
        }
        System.out.println(master.zrank("score","小龙"));
        Set<Tuple> score1 = master.zrevrangeWithScores("score", 0, 10);
        for (Tuple tuple : score1) {
            System.out.println(tuple.getElement());
            System.out.println(tuple.getScore());
        }
    }
}
